package com.roc.web.action.merchantrans;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

public class MerchantTransQuerySearchCondition extends BaseSearchCondition{
	private String merchantNO;
	private String minDate;
	private String maxDate;
	private String moneyRange;
	private String areaCode;
	private String mccType;
	private String mcc;
	private String orgCode;
	
	
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		// TODO Auto-generated method stub
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		if(Constance.isNotEmpty(merchantNO)){ //商户号
			filedBeanList.add(new WhereHQLFieldBean("t.merchantNo", merchantNO.trim(), "=", false));
		}
		if (Constance.isNotEmpty(minDate) && Constance.isNotEmpty(maxDate)) {
			//Date startDate = Constance.formateDate(minDate);
			//Date endDate = Constance.formateDate(maxDate);
			String startDate = minDate.replace("-", "");
			String endDate = maxDate.replace("-", "");
			filedBeanList.add(new WhereHQLFieldBean("t.transDate", startDate,
					">=", false));
			filedBeanList.add(new WhereHQLFieldBean("t.transDate", endDate,
					"<=", false));
		}
		if(Constance.isNotEmpty(moneyRange)){ //商户号
			if(moneyRange.trim().equals("1")){
				filedBeanList.add(new WhereHQLFieldBean("t.totalAmt",10000.00,">=",false));
				filedBeanList.add(new WhereHQLFieldBean("t.totalAmt",20000.00,"<",false));
			}else if(moneyRange.trim().equals("2")){
				filedBeanList.add(new WhereHQLFieldBean("t.totalAmt",20000.00,">=",false));
				filedBeanList.add(new WhereHQLFieldBean("t.totalAmt",30000.00,"<",false));
			}else if(moneyRange.trim().equals("3")){
				filedBeanList.add(new WhereHQLFieldBean("t.totalAmt",30000.00,">=",false));
				filedBeanList.add(new WhereHQLFieldBean("t.totalAmt",40000.00,"<",false));
			}else if(moneyRange.trim().equals("4")){
				filedBeanList.add(new WhereHQLFieldBean("t.totalAmt",40000.00,">=",false));	
			}
		}
		if(Constance.isNotEmpty(areaCode)&&!areaCode.equals("99")){ 
			filedBeanList.add(new WhereHQLFieldBean("t.areaCode", areaCode.trim(), "=", false));
		}
		if(Constance.isNotEmpty(mccType)&&!mccType.equals("99")){ 
			filedBeanList.add(new WhereHQLFieldBean("t.mccType", mccType.trim(), "=", false));
		}
		if(Constance.isNotEmpty(mcc)){ 
			filedBeanList.add(new WhereHQLFieldBean("t.mcc", mcc.trim(), "=", false));
		}
		if(Constance.isNotEmpty(orgCode)&&!"99".equals(orgCode)){ //机构号
			filedBeanList.add(new WhereHQLFieldBean("m.belongBranch", orgCode.trim(), "=", false));
		}
		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		// TODO Auto-generated method stub
		return "select count(*) from TransReport t,Esmidinfo m where t.merchantNo=m.mid";
	}

	@Override
	protected String getSearchHQL() {
		// TODO Auto-generated method stub
		return "select t.merchantNo,t.merName,t.mccType,t.mcc,t.areaCode,t.totalAmt,t.totalFee,t.totalNum,t.transDate,t.avgAmt,t.feeType,m.belongBranch  " +
				" from TransReport t,Esmidinfo m where t.merchantNo=m.mid ";
	}

	@Override
	protected String getOrderPartOfHQL() {
		// TODO Auto-generated method stub
		return "  order by t.transDate ";
	}

	public String getMerchantNO() {
		return merchantNO;
	}

	public void setMerchantNO(String merchantNO) {
		this.merchantNO = merchantNO;
	}

	public String getMinDate() {
		return minDate;
	}

	public void setMinDate(String minDate) {
		this.minDate = minDate;
	}

	public String getMaxDate() {
		return maxDate;
	}

	public void setMaxDate(String maxDate) {
		this.maxDate = maxDate;
	}

	public String getMoneyRange() {
		return moneyRange;
	}

	public void setMoneyRange(String moneyRange) {
		this.moneyRange = moneyRange;
	}

	public String getAreaCode() {
		return areaCode;
	}

	public void setAreaCode(String areaCode) {
		this.areaCode = areaCode;
	}

	public String getMccType() {
		return mccType;
	}

	public void setMccType(String mccType) {
		this.mccType = mccType;
	}

	public String getMcc() {
		return mcc;
	}

	public void setMcc(String mcc) {
		this.mcc = mcc;
	}

	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}

	
	
	
	

}
